#include <stdio.h>

bool isPost(int A[],int n)
{
	if(n==0)
		return true;
	int* left=A;
	int ln=0;
	while(left[ln]<A[n-1])
		ln++;
	int* right=A+ln;
	int rn=0;	
	while(right[rn]>A[n-1])
		rn++;
	if(ln+rn!=n-1)
		return false;
	else
	{
		return isPost(left,ln)&&isPost(right,rn);
	}
}

int main()
{
	int A[]={5,7,6,9,11,10,8};
	int B[]={7,4,6,5};
	if(isPost(B,4))
		printf("true\n");
	else
		printf("false\n");
	return 0;
}
